/*
 * OrderDao.java
 *
 * Version 1.0
 *
 * 10.07.2011
 *
 * (c) Arthur Borisow arthur.borisow[at]gmail.com
 */

package com.softserveinc.edu.oms.persistence.dao.concrete;

import java.util.Date;
import java.util.List;

import org.hibernate.SessionFactory;
import org.hibernate.criterion.Restrictions;

import com.softserveinc.edu.oms.persistence.dao.HibernateDao;
import com.softserveinc.edu.oms.persistence.dao.params.SelectCondition;
import com.softserveinc.edu.oms.persistence.entities.Order;
import com.softserveinc.edu.oms.persistence.entities.OrderStatus;

/**
 * @author arthur.borisow
 * 
 */
public class OrderDao extends HibernateDao<Order> {

	public OrderDao(final SessionFactory sessionFactory) {
		super(Order.class, sessionFactory);
	}

	public List<Order> findByTotalPrice(final double totalPrice,
			final SelectCondition cond) {
		return findByCriterions(cond.createDoubleCriterion("totalPrice",
				totalPrice));
	}

	public List<Order> findByDeliveryDate(final Date deliveryDate,
			final SelectCondition cond) {
		return findByCriterions(cond.createDateCriterion("deliveryDate",
				deliveryDate));
	}

	public List<Order> findByOrderDate(final Date orderDate,
			final SelectCondition cond) {
		return findByCriterions(cond
				.createDateCriterion("orderDate", orderDate));
	}

	public List<Order> findByOrderStatus(final OrderStatus orderStatus) {
		return findByCriterions(Restrictions.eq("orderStatus", orderStatus));
	}

}
